import dayjs from 'dayjs'
import useI18n from "@/i18n/index.js";

const i18n = useI18n.global

export const propsConfig = {
  modelValue: {
    type: Object,
    required: true
  },

  size: {
    type: String,
    default: 'default' // ["", "default", "small", "large"]
  },
  rules: {
    type: Object,
    default: {}
  },
  formItems: {
    type: Array,
    default: []
  },
  labelWidth: {
    type: String,
    default: '100px'
  },
  // 表单域标签后缀
  labelSuffix: {
    type: String,
    default: ''
  },
  itemStyle: {
    type: Object,
    default: () => ({ padding: '2px 2px' })
  },
  labelPosition: {
    type: String,
    default: 'left'
  },
  layoutVertical: {
    type: Boolean,
    default: () => false
  },

  rightStyle: {
    type: Object,
    default: () => ({
      width: 'auto',
    })
  },
  // 右插槽是否显示
  rightTemplateVisible: {
    type: Boolean,
    default: true
  },
  // 禁用
  disabled: {
    type: Boolean,
    default: false
  },

  // 是否展示标题提示
  infoVisible: {
    type: Boolean,
    default: false
  },

  info: {
    type: String,
    default: ''
  }
}

export const dateRangeOption = {
  type: 'datetimerange',
  rangeSeparator: i18n.t('customForm.props.891496-0'),
  startPlaceholder: i18n.t('customForm.props.891496-1'),
  endPlaceholder: i18n.t('customForm.props.891496-2'),
  pickerOptions: {
    shortcuts: [
      {
        text: i18n.t('customForm.props.891496-3'),
        onClick(picker) {
          const end = dayjs().format('YYYY-MM-DD 23:59:59')
          const start = dayjs().format('YYYY-MM-DD 00:00:00')
          picker.$emit('pick', [start, end])
        }
      },
      {
        text: i18n.t('customForm.props.891496-4'),
        onClick(picker) {
          let end = new Date(dayjs().format('YYYY-MM-DD 23:59:59'))
          let start = new Date(dayjs().format('YYYY-MM-DD 00:00:00'))
          end.setTime(start.getTime() - 3600 * 1000 * 24)
          start.setTime(start.getTime() - 3600 * 1000 * 24)
          end = new Date(dayjs(end).format('YYYY-MM-DD 23:59:59'))
          start = new Date(dayjs(start).format('YYYY-MM-DD 00:00:00'))
          picker.$emit('pick', [start, end])
        }
      },
      {
        text: i18n.t('customForm.props.891496-5'),
        onClick(picker) {
          const end = new Date(dayjs().format('YYYY-MM-DD 23:59:59'))
          const start = new Date(dayjs().format('YYYY-MM-DD 00:00:00'))
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 3)
          picker.$emit('pick', [start, end])
        }
      },
      {
        text: i18n.t('customForm.props.891496-6'),
        onClick(picker) {
          const end = new Date(dayjs().format('YYYY-MM-DD 23:59:59'))
          const start = new Date(dayjs().format('YYYY-MM-DD 00:00:00'))
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
          picker.$emit('pick', [start, end])
        }
      },
      {
        text: i18n.t('customForm.props.891496-7'),
        onClick(picker) {
          const end = new Date(dayjs().format('YYYY-MM-DD 23:59:59'))
          const start = new Date(dayjs().format('YYYY-MM-DD 00:00:00'))
          start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
          picker.$emit('pick', [start, end])
        }
      }
    ]
  },
  valueFormat: 'yyyy-MM-dd HH:mm:ss'
}
